package springcloudeDemo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author LuckW
 */
@RestController
public class EurekaConsumerController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private HelloService helloService;

    @GetMapping("/consumerHello")
    public String consumerHello() {
        return String.format(restTemplate
                .getForEntity("http://eureka-provider/index", String.class)
                .getBody()+"%s","-consumer");
    }

    @GetMapping("/consumerservice")
    public String helloService(){
        return helloService.helloService();
    }

}
